export const link = (roomKey) => {

    if (Game.rooms[roomKey].controller.level >= 5 &&
        (Memory.Rooms[roomKey].links.targetLink.length > 0 ||
            Memory.Rooms[roomKey].links.sourceLink.length > 0)) {
        /**
         * 能量矿数组
         * @type {StructureLink[]}
         */
        const sourceLink = Memory.Rooms[roomKey].links.sourceLink.map((id) => {
            return Game.getObjectById(id)
        })
        const targetLink = Memory.Rooms[roomKey].links.targetLink.map((id) => {
            return Game.getObjectById(id)
        })
        for (const sourceLinkElement of sourceLink) {
            if (sourceLinkElement.store.getFreeCapacity(RESOURCE_ENERGY) < 400 && sourceLinkElement.cooldown === 0) {
                sourceLinkElement.transferEnergy(targetLink[0])
            }
        }

    }


}